#include<bits/stdc++.h>
using namespace std;
const int N=100005;
int main(){
    int t,n,m,l,v;
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);

    cin >> t;
    int d[N];
    int v1[N];
    int a[N];
    int p[N];
    int f = 0;

    while(t--) {
        int sum = 0;
        int ma = INT_MIN;
        int mi = INT_MAX;
        cin >> n >> m >> l >> v;
        for (int i = 1; i <= n; i++) {
            cin >> d[i] >> v1[i] >> a[i];
        }
        for (int i = 1; i <= m; i++) {
            cin >> p[i];
        }

        sort(p+1,p+m+1);
        for (int i = 1; i <= n; i++) {

            if(v1[i] > v) {
                if(d[i] <= p[m]) {
                    sum++;
                }


            } else if(a[i] > 0){

                double dis=((v*v*1.0)-(v1[i]*v1[i]))/ (2*a[i]);

                if(dis + d[i] < p[m]) {
                    sum++;
                }

            }
        }
        cout << sum << " ";
        if(sum == 0) {
            cout << m << endl;
        } else {
            cout << m-1 << endl;
        }

    }


    return 0;
}
